<?php

/**
 * Controller is the customized base controller class.
 * All controller classes for this application should extend from this base class.
 */
class BaseController extends CController {

    /**
     * @var string the default layout for the controller view. Defaults to '//layouts/column1',
     * meaning using a single column layout. See 'protected/views/layouts/column1.php'.
     */
    public $layout = '//layouts/main';

    /**
     * @var array context menu items. This property will be assigned to {@link CMenu::items}.
     */
    public $menu = array();

    /**
     * @var array the breadcrumbs of the current page. The value of this property will
     * be assigned to {@link CBreadcrumbs::links}. Please refer to {@link CBreadcrumbs::links}
     * for more details on how to specify this property.
     */
    public $breadcrumbs = array();
    private $_pageTitle;
    private $_pageClass;
    public $pageMetaDescription = '';
    public $pageMetaKeywords = '';
    private $_actionMember;

    public function init() {
        parent::init();
        Yii::app()->setLanguage('en');
    }

    /**
     * @return string the page title. Defaults to the controller name and the action name.
     */
    public function getPageTitle() {
        if ($this->_pageTitle !== null) {
            return ($this->_pageTitle !== "") ? $this->_pageTitle : Yii::app()->name;
            //return ($this->_pageTitle!=="")?$this->_pageTitle . ' - ' . Yii::app()->name : Yii::app()->name;
        } else {
            $name = ucfirst(basename($this->getId()));
            if ($this->getAction() !== null && strcasecmp($this->getAction()->getId(), $this->defaultAction))
                return $this->_pageTitle = ucfirst($this->getAction()->getId()) . ' - ' . Yii::app()->name;
            else
                return $this->_pageTitle = $name . ' - ' . Yii::app()->name;
        }
    }

    public function setPageTitle($value) {
        $this->_pageTitle = $value;
    }
    
    /**
     * @return string the page title. Defaults to the controller name and the action name.
     */
    public function getPageClass() {
        $result = '';
        if ($this->_pageClass !== null) {
            $result = ($this->_pageClass !== "") ? ' class="'.$this->_pageClass.'"':'';            
        }
        return $result;
    }

    public function setPageClass($value) {
        $this->_pageClass = $value;
    }
    
    public function getActionMember() {        
        return $this->_actionMember;
    }

    public function setActionMember($value) {
        $this->_actionMember = $value;
    }

}